$(function(){
	options = {					 
			 chart: {			
				type: 'column',
				backgroundColor: {
					 linearGradient: { x1: 0, y1: 0, x2: 1, y2: 1 },
					 stops: [ [0, 'rgb(255, 255, 255)'], [1, '#eeeeee'] ]
				},
				borderWidth: 0,
				plotBackgroundColor: 'rgba(255, 255, 255, .9)',
				plotShadow: true, 
				plotBorderWidth: 1,					
		        zoomType: 'xy',
    			renderTo: 'container'  ,
    			marginLeft:60,
    			marginRight: 20,
                marginBottom: 30
             },
			 title: {text:'最近一个月文章总数统计',x: -20 },		
		     subtitle: { text:'', x: -20 },
		     legend: {
		            enabled: false
		        },
	        xAxis: {
	        	gridLineWidth: 1,
	        	lineColor: '#000',
	        	tickColor: '#000',
	        	labels: { 
	        		style: { 
	        			color: '#000',
	        			font: '11px Trebuchet MS, Verdana, sans-serif',
	        			fontSize:'10px' //刻度字体大小
	        		} 
		     	},
		     	title: { 
		     		text: '最近24小时',
		     		style: {
		     			color: '#333',
		     			fontWeight: 'bold', 
		     			fontSize: '12px', 
		     			fontFamily: 'Trebuchet MS, Verdana, sans-serif' 
		     		} 
		     	}
	        },
	        yAxis: { 
	        	minorTickInterval: 'auto',
	        	lineColor: '#000',
	        	lineWidth: 1,
	        	tickWidth: 1,
	        	tickColor: '#000',
	        	labels: { style: { color: '#000', font: '11px Trebuchet MS, Verdana, sans-serif' } },
	            title: {
	                text: '投 稿 数',
	                style: {color: '#333', fontSize: '12px'}
	            },
	            plotLines: [{
	                value: 0,
	                width: 1,
	                color: '#808080'
	            }]
	        }, 
	        tooltip: {
	            headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
	            pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
	                '<td style="padding:0"><b>{point.y:.1f}</b></td></tr>',
	            footerFormat: '</table>',
	            shared: true,
	            useHTML: true
	        },
            plotOptions: {
            	 line: { 
            		 dataLabels:{
            			 enabled: false
            		 },
            		 enableMouseTracking: true
            	},
               column: {
                    pointPadding: 0.2,
                    borderWidth: 0,
                    depth: 10
                }		        	
            },		                        
	        series: []	
	}; 		
	
	
	XJoptions = {					 
			 chart: {			
				type: 'column',
				backgroundColor: {
					 linearGradient: { x1: 0, y1: 0, x2: 1, y2: 1 },
					 stops: [ [0, 'rgb(255, 255, 255)'], [1, '#eeeeee'] ]
				},
				borderWidth: 0,
				plotBackgroundColor: 'rgba(255, 255, 255, .9)',
				plotShadow: true, 
				plotBorderWidth: 1,					
		        zoomType: 'xy',
   			renderTo: 'xjChar'  ,
   			marginLeft:60,
   			marginRight: 20,
               marginBottom: 30
            },
			 title: {text:'文章总数排名',x: -20 },		
		     subtitle: { text:'', x: -20 },
		     legend: {
		            enabled: false
		        },
	        xAxis: {
	        	gridLineWidth: 1,
	        	lineColor: '#000',
	        	tickColor: '#000',
	        	labels: { 
	        		style: { 
	        			color: '#000',
	        			font: '11px Trebuchet MS, Verdana, sans-serif',
	        			fontSize:'10px' //刻度字体大小
	        		} 
		     	},
		     	title: { 
		     		text: '科室',
		     		style: {
		     			color: '#333',
		     			fontWeight: 'bold', 
		     			fontSize: '12px', 
		     			fontFamily: 'Trebuchet MS, Verdana, sans-serif' 
		     		} 
		     	}
	        },
	        yAxis: { 
	        	minorTickInterval: 'auto',
	        	lineColor: '#000',
	        	lineWidth: 1,
	        	tickWidth: 1,
	        	tickColor: '#000',
	        	labels: { style: { color: '#000', font: '11px Trebuchet MS, Verdana, sans-serif' } },
	            title: {
	                text: '投 稿 数',
	                style: {color: '#333', fontSize: '12px'}
	            },
	            plotLines: [{
	                value: 0,
	                width: 1,
	                color: '#808080'
	            }]
	        }, 
	        tooltip: {
	            headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
	            pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
	                '<td style="padding:0"><b>{point.y:.1f}</b></td></tr>',
	            footerFormat: '</table>',
	            shared: true,
	            useHTML: true
	        },
           plotOptions: {
           	 line: { 
           		 dataLabels:{
           			 enabled: false
           		 },
           		 enableMouseTracking: true
           	},
              column: {
                   pointPadding: 0.2,
                   borderWidth: 0,
                   depth: 10
               }		        	
           },		                        
	        series: []	
	};
	
	charAjax(datagridUrl);			
	
});


function DeptCharHtml(url,divId) {	
		//创建图表
		$.ajax({  
			type: "POST",  
	        url: url, 				  
		    type:'post',  
		    cache:false,  
		    dataType:'json',  
		    success:function(map) {   	    
		    	XJoptions.series=[]; 
   			    var nameArray=[];
   			    var yArray=[];		   	
		    	if(map!=null&&map!=""){				    				    
		    		for(var i=0;i<map.length;i++){	    	    			
		    			nameArray.push(map[i].orgIdName);
		    			yArray.push(map[i].remark);
		    		}    	    		
		    		var AQIArr={name :"文章总数", data : eval("["+yArray.join(',')+"]")} ;
		    		XJoptions.series.push(AQIArr);		   				
		    	}   	
		    	// 设置X轴			 
		    	XJoptions.xAxis.categories = nameArray;
			    XJoptions.subtitle.text = getPreDay(30);
			    //XJoptions.chart.renderTo=divId;
			 	XJchart = new Highcharts.Chart(XJoptions);
		     },  
		     error : function() {  }  
		});	
}

//审核文章 isAudit=yes		
function auditArticle(id){ 		
		art.dialog.open('../ArticleList/updateInterfaceAudit.htm?type=edit&isAudit=yes&id='+id,{
			title: '',
			lock:true,
		  	width: '98%',
		    height: '98%'												   												   
		});
}

function editAdvisory(index){  //回复留言
	art.dialog.open('../advisoryMsgController/updateInterface.htm?opType=edit&id='+index,{
		title: '',
		id:'editDialog',
		lock:true,
	  	width: '90%',
	    height: '90%'												   												   
	});
	}

function delAdvisory(index){  //删除操作
	art.dialog({
		icon: 'question',	
		width:250,
	    content: '你确定删除该垃圾留言？',
	    ok: function () {				    	
	    	$.ajax({
				type:'POST',
				dataType:'json',
				async:false,
				url:'../advisoryMsgController/delete.json',
				data:{id:index,delSub:true},
				success:function(data){
					if(data.success=true){									
						art.dialog.alert('删除成功！');
						window.location.reload();  
					}else{
						art.dialog.alert('删除失败，请联系管理员！');
					}
				}
			});
	    },
	    cancelVal: '取消',
	    cancel: true 
	});				
}

function timeStamp2String(time,geshi){  
    var datetime = new Date();  
    datetime.setTime(time);  
    var year = datetime.getFullYear();  
    var month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1;  
    var date = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate();  
    var hour = datetime.getHours()< 10 ? "0" + datetime.getHours() : datetime.getHours();  
    var minute = datetime.getMinutes()< 10 ? "0" + datetime.getMinutes() : datetime.getMinutes();  
    var second = datetime.getSeconds()< 10 ? "0" + datetime.getSeconds() : datetime.getSeconds();  
    if(geshi=="1"){
    	 return year + "-" + month + "-" + date+" "+hour+":"+minute;  
    }else if(geshi=="2"){
    	return year + "-" + month + "-" + date;  
    }else if(geshi=="3"){
    	 return date+"日"+hour+"时"; 
    }
}

function getPreDay(num){
	var d = new Date(); //获取一个月前
	d.setDate(d.getDate() - num);		
	var mon=d.getMonth()+1;
	var day=d.getDate();			
	var str = d.getFullYear()+"/"+(mon<10 ? "0"+ mon : mon)+"/"+(day<10?"0"+day:day);
	
	var d2 = new Date(); //获取今天日期			
	var mon2=d2.getMonth()+1;
	var day2=d2.getDate();			
	var str2 = d2.getFullYear()+"/"+(mon2<10 ? "0"+ mon2 : mon2)+"/"+(day2<10?"0"+day2:day2);			
	return str+"——"+str2;
}